<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //splice() 方法通过删除或替换现有元素或者原地添加新的元素来修改数组，并以数组形式返回被修改的内容。此方法会改变原数组。
        // splice(start, deleteCount, item1, item2, /* …, */ itemN)
        /* 
            start:起始下标，若大于数组长度则不删除元素直接添加
            deleteCount：从起始下标开始要删除的元素个数，为0的话代表不删除
            item1...n:在删除后的位置用什么元素来替代
        */
        const array1 = ['aa','bb','cc','dd','ee','ff'];
        array1.splice(2,1,'ss','yy');
        console.log(array1);

        const months = ['Jan', 'March', 'April', 'June'];
        // months.splice(1, 0, 'Feb'); //'Jan', 'Feb' 'March', 'April', 'June'
        console.log(months);
        months.splice(4, 1, 'May'); //'Jan', 'March', 'April', 'June'  'May'
        console.log(months);
    </script>
</head>
<body>
    
</body>
</html>